package no.ntnu.item.ttm4115.termproject.multiplechoicequestionagent;

import no.ntnu.item.ttm4115.termproject.CorrectQuestionAnswer;
import no.ntnu.item.ttm4115.termproject.ForwardedFinalQuestionAnswer;
import no.ntnu.item.ttm4115.termproject.InfoToQuestion;
import no.ntnu.item.ttm4115.termproject.QuestionToGroupGameAgent;
import no.tellu.common.actorframe.messages.RoleRemoveMsg;


public class MultipleChoiceQuestionAgentActions extends Object {

	public static void sendQuestionsToGroup(InfoToQuestion signal, MultipleChoiceQuestionAgentSM asm){
		
		System.out.println("****************************************");
		
		asm.pointAchived = signal.question.getMaxPoints();
		asm.minusForWrongAnswers = signal.question.getMinusPoints();
		asm.question = signal.question;
		asm.sendMessage(new QuestionToGroupGameAgent(signal.question.getOptions(),signal.question.getQuestionText()), signal.groupGameAddress);
		System.out.println(signal.question.getQuestionText().firstElement());
		//System.out.println(((SessionOption)signal.question.getOptions().get(1)).getAnswerOption());
	}

	public static void informWrongAnswer(ForwardedFinalQuestionAnswer signal, MultipleChoiceQuestionAgentSM asm){
		asm.minusAchivedForWrongAnswers =asm.minusAchivedForWrongAnswers + asm.minusForWrongAnswers;
		asm.sendMessage(new QuestionToGroupGameAgent(asm.question.getQuestionText(),asm.question.getOptions()),signal.getSenderRole());
	}

	public static void InformCorrectAnswer(ForwardedFinalQuestionAnswer signal, MultipleChoiceQuestionAgentSM asm){
	    asm.pointAchived = asm.pointAchived - asm.minusAchivedForWrongAnswers;
			asm.sendMessage(new CorrectQuestionAnswer(asm.pointAchived,signal.groupAddress), asm.getContext().getParentAddress());
			//asm.sendMessage(new RoleRemoveMsg(), asm.getMyActorAddress());
	}

	public static boolean correctAnswer(ForwardedFinalQuestionAnswer signal, MultipleChoiceQuestionAgentSM asm){
		if(signal.answer==asm.question.getCorrectAnswerIndex()){
			return true;
		}
		else{    
			return false;
		}
	}



}
